package com.laicunba.service;

import java.math.BigDecimal;
import java.util.List;

import com.laicunba.pojo.FinancingTargetBidDO;
import com.laicunba.pojo.param.Page;
import com.laicunba.pojo.vo.CPBBidGroupVO;
import com.laicunba.pojo.vo.CPBBidVO;
import com.laicunba.pojo.vo.FinancingTargetBidVO;
import com.laicunba.pojo.vo.SCBGroupVO;

public interface FinancingTargetBidService extends BaseService {

	List<FinancingTargetBidDO> findByCertificateId(String certificateId);

	FinancingTargetBidDO findOneByCertificateId(String certificateId);

	List<FinancingTargetBidVO> findByFinancingTargetId(String financingTargetId);

	List<FinancingTargetBidVO> findLast(int rows);

	List<FinancingTargetBidDO> findWithdrawAble(String userId, String type);

	boolean subtractAmount(String id, BigDecimal subtractPrincipal, BigDecimal subtractProfit);

	public int countByFinancingTargetId(String financingTargetId);

	List<FinancingTargetBidVO> findByFinancingTargetIdWithLimit(String financingTargetId, Page page);

	List<CPBBidGroupVO> findCPBGroup(String userId);

	List<CPBBidVO> findCPBVO(String userId, String financingTargetId);

	SCBGroupVO findSCBGroup(String userId);

	/**
	 * 首次购买
	 * 
	 * @param userId
	 * @return
	 */
	boolean isFirstBid(String bidUserId);

	BigDecimal countProfit(String userId, String withdrawType);

	List<FinancingTargetBidDO> findRewardBid(String userId);

	BigDecimal countRewardProfit(String userId);

	public int countActivityTarget(String userId, String targetId, String channel);

	/**
	 * 计算指定标的剩余收益
	 * 
	 * @param bidDO
	 * @return
	 */
	BigDecimal countRemainProfit(FinancingTargetBidDO bidDO);

	/**
	 * 得到可以兑付的活动购买数据
	 * 
	 * @param limit
	 * @return
	 */
	List<FinancingTargetBidDO> findUpcomingActivityBids(int limit);

	public List<FinancingTargetBidVO> findFinancingTargetBidVOList(String userId, String beginTimeStr, String endTimeStr, String targetNameStr, String timeTypeStr, String borrowerId);

	List<FinancingTargetBidDO> findUpcomingFixBids(int limit);

	/**
	 * 计算活动标的收益
	 * 
	 * @param userId
	 * @return
	 */
	BigDecimal countActivityProfit(String userId);

	/**
	 * 
	 * @param userId
	 * @return
	 */
	int countFixBidRows(String userId);

	/**
	 * 添加现金券金额
	 * 
	 * @param id
	 * @param amount
	 * @return
	 */
	boolean addCashCouponAmount(String id, BigDecimal amount);

	List<CPBBidGroupVO> findExpireFixBidGroup(String userId);

	List<CPBBidGroupVO> findNoExpireFixBidGroup(String userId);

	public List<CPBBidVO> findAllFixBidVO(String userId, String targetId);
	
	List<CPBBidVO> findExpireFixBidVO(String userId, String targetId);

	List<CPBBidVO> findNoExpireFixBidVO(String userId, String targetId);

	List<FinancingTargetBidDO> findListBidFromUserId(String userId, String payTimeStr1, String payTimeStr2, String endProfitTimeStr1, String endProfitTimeStr2);

	/**
	 * 设置到期后转银行卡
	 * 
	 * @param uid
	 * @param bidId
	 * @return
	 */
	boolean updateFlagExpiredTransfer2Bank(String uid, String bidId);

	/**
	 * 设置到期后转活期
	 * 
	 * @param uid
	 * @param bidId
	 * @return
	 */
	boolean updateFlagExpiredTransfer2Current(String uid, String bidId);

	/**
	 * 增加加息额度
	 * 
	 * @param id
	 * @param rate
	 * @return
	 */
	boolean addRate(String id, BigDecimal rate);

	boolean updateSummary(String certificateId, String summary);

	/**
	 * 查询活动期间可复投的标的
	 * 
	 * @param userId
	 * @return
	 */
	public List<FinancingTargetBidVO> findReinvestBidList(String userId);

	/**
	 * 统计用户定转活的数量
	 * 
	 * @param userId
	 * @return
	 */
	public int countFixBid2Demand(String userId);

	/**
	 * 冻结标的
	 * 
	 * @param bid
	 * @param summary
	 * @return
	 */
	boolean frozen(String bid, String summary);
	/**
	 * 删除一个活动标(只作更新)
	 * @param bid
	 * @return
	 */
	boolean deleteActivityBid(String bid);
	/**
	 * 更新到期赠息金额
	 * @param bid
	 * @param amount
	 * @return
	 */
	boolean updateExpireSendProfit(String bid, BigDecimal amount);
	/**
	 * 获得即将到期的存管定期标
	 * @param limit
	 * @return
	 */
	List<FinancingTargetBidDO> findUpcomingJzhFixBids(int limit);
}
